/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sorts;

import java.util.Random;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Matias
 */
public class Sorts {

    public static void main(String[] args) {
        // TODO code application logic here
        int cantidad = 2000;
        String ordenado = "";
        
        int[] list = new int[2000];
        int[] list2 = new int[2000];
        int[] list3 = new int[2000];
        int[] list4 = new int[2000];
        int[] temporal = new int[2000];
        Random randomGenerator = new Random();
        try {
            PrintWriter escribir = new PrintWriter("numeros.txt");
        
            for (int idx = 0; idx < cantidad; ++idx){
              int randomInt = randomGenerator.nextInt(1000);
              list[idx] = randomInt;
              escribir.print(randomInt + " ");
              System.out.print(randomInt+"\t");
            }
            escribir.close();
        }catch (Exception e){
            System.out.println("Error al escribir");
        }
        
        
        for (int i = 0; i < 1999; i ++){
            list2[i] = list[i];
            list3[i] = list[i];
            list4[i] = list[i];
        }
                
        selectionSort.sort(list, cantidad);
        bubbleSort.sort(list2, cantidad);
        quickSort.sort(list3, cantidad);
        mergeSort.sort(list4,temporal,0,1000,2000);
        
        for (int str = 0; str < 1999; str ++){
            ordenado += list[str] + " ";
        }
        PrintWriter escribir = null;
        try {
            escribir = new PrintWriter("numeros.txt");
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Sorts.class.getName()).log(Level.SEVERE, null, ex);
        }
        escribir.print(ordenado);
        escribir.close();
    }
}
